package common.convert;

import common.enums.BaseEnum;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
import org.springframework.lang.Nullable;

/**
 * @title
 * @description
 * @usage
 * @copyright Copyright 2014  rrmj Corporation. All rights reserved.
 * @company 上海众多美网络科技有限公司
 * @author weseal
 * @create 2018/4/18
 */

//@WritingConverter
public class EnumWriteConvert<E extends BaseEnum<?, T>,T> implements Converter<E,T> {

	@Nullable
	@Override
	public T convert(E source) {
		return ObjectUtils.defaultIfNull(source.getCode(),null);
	}
}
